package com.nova.android.tvlauncher

import android.annotation.SuppressLint
import com.nova.android.tvlauncher.bean.atv_bean.ConfigLocalDto
import com.nova.android.tvlauncher.bean.atv_bean.CusChanelDto
import com.nova.android.tvlauncher.bean.atv_bean.HomeParentDto
import com.nova.android.tvlauncher.bean.atv_bean.Notification
import com_github_lib_base.bean.FavoriteApp
import com_github_lib_base.ext.cache.preference

@SuppressLint("StaticFieldLeak")
object AppCache {

    var token: String? by preference("token", null)
    var time: Int by preference("time", 0)

    var notificationList: MutableList<Notification.StorageDevice> by preference("notificationList", mutableListOf())
    var notification: Notification.StorageDevice? by preference("notification", null)
    var favoriteAppList: MutableList<FavoriteApp> by preference("favorite_app_list", mutableListOf())
    var channelList: MutableList<CusChanelDto> by preference("channel_list", mutableListOf())
    var homeParentList: MutableList<HomeParentDto> by preference("home_parent_list", mutableListOf())
    var configLocalDto: ConfigLocalDto? by preference("config_local", null)

    var updateInfo: String by preference("update_info", "")

    fun debug() {
    }
}

// 第一次运行
fun firstRun() {
    AppCache.token = "abc123"
    AppCache.time = 13579

    AppCache.debug()
}

// 第二次运行（重启后）
fun secondRun() {
    AppCache.debug()
}